package com.ruoyi.tranShort.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tranShort.domain.ShortMqttConfig;
import com.ruoyi.tranShort.service.IShortMqttConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * mqtt配置Controller
 * 
 * @author ruoyi
 * @date 2021-08-09
 */
@Api("mqtt配置")
@RestController
@RequestMapping("/tranShort/mqttConfig")
public class ShortMqttConfigController extends BaseController
{
    @Autowired
    private IShortMqttConfigService shortMqttConfigService;



    /**
     * 获取mqtt单个配置信息
     */
    @ApiOperation("获取mqtt配置信息")
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo()
    {
        return AjaxResult.success(shortMqttConfigService.selectShortMqttConfig());
    }

    /**
     * 连接mqtt配置
     */
    @Log(title = "mqtt配置", businessType = BusinessType.UPDATE)
    @ApiOperation("连接")
    @PostMapping("/connect")
    public AjaxResult connect(@RequestBody ShortMqttConfig shortMqttConfig)
    {
        return toAjax(shortMqttConfigService.updateShortMqttConfig(shortMqttConfig));
    }



    /**
     * 测试
     * @param shortMqttConfig
     * @return
     */
    @ApiOperation("连接测试")
    @PostMapping("/connectTest")
    public AjaxResult connectTest(@RequestBody ShortMqttConfig shortMqttConfig){
        return toAjax(shortMqttConfigService.connectTest(shortMqttConfig));
    }
}
